package com.knight.hadoop.day05.jvm;

import java.util.ArrayList;

public class TestMemory {
	static class OOMObject{
		public byte[] placeHolder = new byte[64*1024];
	}
	
	public static void fillHeap(int num) throws Exception{
		ArrayList<OOMObject> list = new ArrayList<>();
		for(int i=0;i<num;i++){
			Thread.sleep(50);
			list.add(new OOMObject());
		}
	}
	
	public static void main(String[] args) throws Exception {
		Thread.sleep(10000);
		fillHeap(1000);
		System.out.println("循环结束");
		System.gc();
		Thread.sleep(500000);
	}
}
